#include "HT_update.h"
#include "device.h"
#include "definitions.h"

void UART_Initialize( void )
{
    //UART5
    U5MODE = 0x8;
    /* Enable UART5 Receiver and Transmitter */
    U5STASET = (_U5STA_UTXEN_MASK | _U5STA_URXEN_MASK );
    /* BAUD Rate register Setup */
    U5BRG = 129;
    /* Turn ON UART5 */
    U5MODESET = _U5MODE_ON_MASK;
   
    //UART4
    U4MODE = 0x8;
    /* Enable UART4 Receiver and Transmitter */
    U4STASET = (_U4STA_UTXEN_MASK | _U4STA_URXEN_MASK );
    /* BAUD Rate register Setup */
    U4BRG = 129;
    /* Turn ON UART4 */
    U4MODESET = _U4MODE_ON_MASK;
    
    //UART3
    U3MODE = 0x8;
    /* Enable UART3 Receiver and Transmitter */
    U3STASET = (_U3STA_UTXEN_MASK | _U3STA_URXEN_MASK );
    /* BAUD Rate register Setup */
    U3BRG = 129;
    /* Turn ON UART3 */
    U3MODESET = _U3MODE_ON_MASK;
    
    //UART1
    U1MODE = 0x8;
    /* Enable UART1 Receiver and Transmitter */
    U1STASET = (_U1STA_UTXEN_MASK | _U1STA_URXEN_MASK );
    /* BAUD Rate register Setup */
    U1BRG = 129;    // 115200 60MHZ
    /* Turn ON UART1 */
    U1MODESET = _U1MODE_ON_MASK;
}

void SPI_Initialize( void )
{
    SPI2_Initialize();//X-axis + IV-axis
    SPI3_Initialize();//Z-axis
    SPI4_Initialize();//CK(reserved)
    SPI5_Initialize();//Y-axis
    SPI6_Initialize();//Holtek(reserved)
}